package logobj;
import logobj.btd.AnalysisAction;
import logobj.config.ConfProperties;
import logobj.dao.LogDao;
import logobj.ftpUtil.FTP;
import logobj.utils.OutLog;
import java.util.ArrayList;
import java.util.Map;

public class App 
{
    public static void main( String[] args ) {
        OutLog.printf("==============加载配置文件，初始化系统！==============");
        Loading.init();
        LogDao logDao = new LogDao();
        if(logDao.runstatus()){
            OutLog.printf("程序已运行！");
        }else {
            logDao.updatestatus(1);
            Map<String, ArrayList> fineinfomap = null;
            if("N".equals(ConfProperties.no_ftp_model.toUpperCase())){
                FTP ftp = new FTP();
                fineinfomap = ftp.start();
                ftp = null;
                if(fineinfomap.get("namelist").size() == 0){
                    OutLog.printf("本次检测FTP文件夹无日志数据！");
                }
                System.gc();
            }else {
                OutLog.printf("已禁用ftp下载！");
            }
            if("Y".equals(ConfProperties.trunca_tetable_status.toUpperCase())  ){

                OutLog.printf("清除数据库数据！");
                logDao.clearTable();
            }
            AnalysisAction analysisAction = new AnalysisAction();
            analysisAction.startAction(fineinfomap);
            logDao.updatestatus(0);
        }
        System.gc();
    }

}
